/*
 *接口编写处...
*如果接口需要做Action的权限验证，请在Action上使用属性
*如: [ApiActionPermission("Sys_City",Enums.ActionPermissionOptions.Search)]
 */
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VOL.Entity.DomainModels;
using VOL.Demo.IServices;

using VOL.Core.BaseProvider;
using VOL.Demo.IRepositories;
using System.Linq;
using Microsoft.EntityFrameworkCore;


namespace VOL.Demo.Controllers
{
    public partial class Sys_CityController
    {
        private readonly ISys_CityService _service;//访问业务代码
        private readonly IHttpContextAccessor _httpContextAccessor;
        private readonly ISys_CityRepository _CityRepository;//访问数据库

        [ActivatorUtilitiesConstructor]
        public Sys_CityController(
            ISys_CityService service,
            IHttpContextAccessor httpContextAccessor,
            ISys_CityRepository cityRepository
         
        )
        : base(service)
        {
            _service = service;
            _httpContextAccessor = httpContextAccessor;
            _CityRepository = cityRepository;
        }
        [Route("getList"), HttpGet]
        public async Task<IActionResult> GetList(string code)
        {
            return Json(await _CityRepository.FindAsIQueryable(x => x.ProvinceCode == code).Select(s => new
            {
                key = s.CityCode,
                value = s.CityName

            }).ToListAsync());

        }
    }
}
